package com.pagepub.core.tag.validator;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

public class ValidateEmptyLenDisplay extends FormValidateBasic {
	/**
	 * 
	 */
	private String submitvalidate;
    private String rightimage;
    private String rightwordcolor="green"; 
	private static final long serialVersionUID = 2068749476600680392L;

	@Override
	public int doStartTag() throws JspException {
		// TODO 自动生成方法存根
		JspWriter out=this.pageContext.getOut();
		try {
			out.print(this.validateemptylendisplay());
		} catch (IOException e) {
			// TODO 自动生成 catch 块

			e.printStackTrace();
		}
		return super.doStartTag();
	}
	
	public StringBuffer validateemptylendisplay(){
		StringBuffer str=new StringBuffer();
		String emptyelement="";
	     String pluselement="";
	      if(this.submitvalidate.equalsIgnoreCase("true")){
				emptyelement="emptyelement(realname);";
				pluselement="else pluselement(realname);";
			}
		str.append(this.returnfunction());
		 str.append("<script language=\"javascript\">");
		str.append("function validateemptylendisplay(realvalue,min,max,spanname,realname) {");
		str.append("if(Validateempty(realvalue,realname,spanname)) "); 
		  str.append("if(ValidateLength(realvalue,min,max,realname,spanname))");
		  str.append("{ displayrightmessage(realvalue,spanname,realname);");	  
//		  if(this.submitvalidate.equalsIgnoreCase("true")){
//				str.append("dilivery(nextelementname);");
//			}
		  str.append(emptyelement);
	   str.append("}");	
	   str.append(pluselement);
	   str.append(pluselement);
	  
		str.append("}");
		str.append("</script>");
		return str;
	}
   public StringBuffer returnfunction(){
	   StringBuffer str=new StringBuffer();
	   ValidateLengthDisplayRightMessage validatedisplaymessage=new ValidateLengthDisplayRightMessage();
	   validatedisplaymessage.setRightimage(rightimage);
	   validatedisplaymessage.setRightwordcolor(rightwordcolor);
	   validatedisplaymessage.setSubmitvalidate(submitvalidate);
	   validatedisplaymessage.setWordcolor(wordcolor);
	   validatedisplaymessage.setWrongimage(wrongimage);
	   str.append(validatedisplaymessage.returnfunction());
	   ValidateEmpty validateempty=new ValidateEmpty();
	   validateempty.setWordcolor(wordcolor);
	   validateempty.setWrongimage(wrongimage);
	   str.append(validateempty.validateempty());
	   return str;
   }
	public String getRightimage() {
		return rightimage;
	}

	public void setRightimage(String rightimage) {
		this.rightimage = rightimage;
	}

	public String getRightwordcolor() {
		return rightwordcolor;
	}

	public void setRightwordcolor(String rightwordcolor) {
		this.rightwordcolor = rightwordcolor;
	}

	public String getSubmitvalidate() {
		return submitvalidate;
	}

	public void setSubmitvalidate(String submitvalidate) {
		this.submitvalidate = submitvalidate;
	}
}
